//
//  CZTabBarController.swift
//  weibo
//
//  Created by 丁蒙 on 16/6/23.
//  Copyright © 2016年 丁蒙. All rights reserved.
//

import UIKit

class CZTabBarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        let tabBar = CZTabBar()
        tabBar.colsure = {
            let nav = CZNavViewController(rootViewController: CZComposeViewController())
            self.presentViewController(nav, animated: false, completion: nil)
        }
        
        setValue(tabBar, forKey: "tabBar")
        
        addChildViewController(CZHomeTableViewController(), title: "首页", imageName: "tabbar_home")
        addChildViewController(CZMessageTableViewController(), title: "消息", imageName: "tabbar_message_center")
        addChildViewController(CZDiscoveryTableViewController(), title: "发现", imageName: "tabbar_discover")
        addChildViewController(CZMyTableViewController(), title: "我", imageName: "tabbar_profile")
    }
    func addChildViewController(VC: UIViewController,title: String,imageName: String) {
        
        VC.tabBarItem.image = UIImage(named: imageName)
        VC.title = title
        VC.tabBarItem.selectedImage = UIImage(named: "\(imageName)_selected")
        let navVC = CZNavViewController(rootViewController: VC)
        self.addChildViewController(navVC)
    }
    
    

}
